@include('Admin.public.head')
<body>
@include('Admin.public.menu')
<div class=" admin-content"  id="app">
  <div class="daohang">

  </div>
  <div class="am-modal am-modal-no-btn" tabindex="-1" id="my-popup">
    <div class="am-modal-dialog">
      <div class="am-modal-hd">修改密码
        <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
      </div>
      <div class="am-popup-bd">
        <form class="am-form tjlanmu">

          <div class="am-form-group am-cf">
            <div class="zuo">新密码：</div>
            <div class="you">
              <input type="password" class="am-form-field" id="doc-ipt-email-1" v-model="pas.newPassword" placeholder="请输入新密码">
            </div>
          </div>
          <div class="am-form-group am-cf">
            <div class="zuo">确认密码：</div>
            <div class="you">
              <input type="password" class="am-form-field" id="doc-ipt-email-1" v-model="pas.confirmPassword" placeholder="再次输入密码">
            </div>
          </div>
          <div class="am-form-group am-cf">
            <button type="button" v-on:click="editPas()" class="am-btn am-btn-success am-radius">确 定</button>
          </div>
        </form>
      </div>
    </div>
  </div>
<div class="admin-biaogelist">
    <div class="listbiaoti am-cf">
      <ul class="am-icon-flag on"> 个人中心</ul>
      {{--<dl class="am-icon-home" style="float: right;"> 当前位置： 首页 > <a href="#">商品列表</a></dl>--}}
    </div>
    <div class="fbneirong" >
      <form class="am-form">
        {{ csrf_field() }}
        <div class="am-form-group am-cf">
          <div class="zuo">用户名：</div>
          <div class="you">
            <input type="text" style="max-width: 300px" class="am-form-field" id="doc-ipt-email-1" readonly="readonly" v-model="users.name" @blur="check()" placeholder="请输入用户名" required>
          </div>
        </div>
        <div class="am-form-group am-cf">
          <div class="zuo">密码：</div>
          <div class="am-input-group" style="max-width: 300px">
            <input type="password" class="am-form-field"  readonly="readonly" v-model="users.password" placeholder="密码">
            <span style="cursor:pointer;"  data-am-modal="{target: '#my-popup',height: 300}"   class="am-input-group-label">修改密码</span>
          </div>
        </div>
        <div class="am-form-group am-cf">
          <div class="zuo">姓名：</div>
          <div class="you">
            <input type="text" style="max-width: 300px" class="am-form-field" v-model="users.user_name" placeholder="请输入姓名" required>
          </div>
        </div>
        <div class="am-form-group am-cf">
          <div class="zuo">电话：</div>
          <div class="you">
            <input type="number" style="max-width: 300px" class="am-form-field" maxlength="11"  v-model="users.phone" placeholder="请输入电话">
          </div>
        </div>
        <div class="am-form-group am-cf">
          <div class="zuo">邮箱：</div>
          <div class="you">
            <input type="text" style="max-width: 300px" class="am-form-field" v-model="users.emil" placeholder="请输入邮箱" required>
          </div>
        </div>
        <div class="am-form-group am-cf">
          <div class="zuo">职位：</div>
          <div class="you">
            <input type="text" style="max-width: 300px" class="am-form-field" readonly="readonly" id="doc-ipt-email-1" v-model="users.position" placeholder="请输入职位" required>
          </div>
        </div>
        <div class="am-form-group am-cf">
          <div class="you" style="margin-left: 11%;">
            <button type="button" class="am-btn am-btn-success am-radius" v-on:click="edit()">修 改</button>&nbsp;&nbsp;
            <button type="button" class="am-btn am-btn-secondary am-radius" onclick="javascript:history.back(-1);">返 回</button>
          </div>
        </div>
      </form>
    </div>
  <script>
      var app = new Vue({
          el:"#app",
          data: {
              users:{
                  name:'',
                  user_name:'',
                  emil:'',
                  phone:'',
                  password:'',
                  position:'',
                  is_branch:0,
                  note:'',
              },
              pas:{
                  newPassword:'',
                  confirmPassword:'',
              },
          },
          //事件
          methods: {
              initialize:function () {
                  $.post("/admin/system/centerSet",{'_token':'{{csrf_token()}}',class:'select'},function (res) {
                      if(res.code){
                          app.users = res.data
                      } else {
                          layer.msg(res.data);
                      }
                  });
              },
              //编辑
              edit:function () {
                  if(app.users.user_name == ''){
                      layer.msg('姓名不能为空');
                      return;
                  }
                  $.post("/admin/system/centerSet",{'_token':'{{csrf_token()}}',class:'edit',user:app.users},function (res) {
                      if(res.code){
                          layer.msg(res.data);
                      } else {
                          layer.msg(res.data);
                      }
                  });
              },
              //编辑
              editPas:function () {

                  if(app.pas.newPassword == ''){
                      layer.msg('新密码不能为空');
                      return;
                  }
                  if(app.pas.confirmPassword == ''){
                      layer.msg('再次确认密码不能为空');
                      return;
                  }
                  if(app.pas.newPassword != app.pas.confirmPassword){
                      layer.msg('两次密码不一致');
                  } else {
                      $.post("/admin/system/centerSet",{'_token':'{{csrf_token()}}',class:'editPas',passwords:app.pas},function (res) {
                          if(res.code){
                              layer.msg(res.data,function () {
                                  window.location.href="/admin/login/login";
                              });
                          } else {
                              layer.msg(res.data);
                          }
                      });
                  }

              },
          },
          //自动执行
          mounted: function () {
              this.initialize();
          },
      })
  </script>
@include('Admin.public.foot')